package com.mf.basic.mapper;

import com.mf.basic.entity.DtoRole;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * Created by Luke on 2025/3/7 16:06.
 */
public interface MapperRole extends BaseMapper<DtoRole> {

    /**
     * 根据用户ID查询角色列表
     * @param userId 用户ID
     * @return List<DtoRole>
     */
    @Select("SELECT * FROM sys_role " +
            "WHERE EXISTS(SELECT 1 FROM sys_user_role WHERE user_id=#{userId} AND sys_user_role.role_id=sys_role.id)")
    List<DtoRole> selectRolesByUserId(Long userId);

}
